package com.caigou.service.impl;

import com.caigou.bean.cms.entity.ArticleSpecialData;
import com.caigou.mapper.cms.ArticleSpecialDataMapper;
import com.caigou.service.ArticleSpecialDataService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleSpecialDataServiceImpl implements ArticleSpecialDataService {

    @Resource
    private ArticleSpecialDataMapper articleSpecialDataMapper;

    @Override
    public ArticleSpecialData saveArticleSpecialData(Integer layoutId, Integer bannerId, String bannerImage, String bannerAlt, String bannerLink,
                                       String title, Integer titleStatus, String titleContent, String articleId, String articleTitle,
                                       String articleInfo, Integer articleImageId, String articleImage, String articleImageAlt,String articleUrl,
                                       String contentTitle, String content) {
        ArticleSpecialData specialData = new ArticleSpecialData();
        specialData.setLayoutId(layoutId);
        specialData.setBannerId(bannerId);
        specialData.setBannerImage(bannerImage);
        specialData.setBannerAlt(bannerAlt);
        specialData.setBannerLink(bannerLink);
        specialData.setTitle(title);
        specialData.setTitleStatus(titleStatus);
        specialData.setTitleContent(titleContent);
        specialData.setArticleId(articleId);
        specialData.setArticleTitle(articleTitle);
        specialData.setArticleInfo(articleInfo);
        specialData.setArticleImageId(articleImageId);
        specialData.setArticleImage(articleImage);
        specialData.setArticleImageAlt(articleImageAlt);
        specialData.setArticleUrl(articleUrl);
        specialData.setContentTitle(contentTitle);
        specialData.setContent(content);
        articleSpecialDataMapper.saveArticleSpecialData(specialData);
        return specialData;
    }

    @Override
    public List<ArticleSpecialData> loadArticleSpecialData(Integer layoutId) {
        return articleSpecialDataMapper.loadArticleSpecialData(layoutId);
    }

    @Override
    public void deleteArticleSpecialData(Integer id) {
        articleSpecialDataMapper.deleteArticleSpecialData(id);
    }

    @Override
    public int deleteArticleSpecialDataByArticleId(String articleId){
        return articleSpecialDataMapper.deleteArticleSpecialDataByArticleId(articleId);
    }
}
